package day8.homeworkII;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

public class Task5 {

    public static void main(String[] args) throws IOException {

        System.out.println("请输入学号-学生姓名");
        System.err.println("注意:输入end为退出");
        Scanner in = new Scanner(System.in);

        File f = new File("C:\\Stu.txt");

        String line = "";
        String name = "";

        try(Writer w = new FileWriter(f)) {
            while (!line.equals("end")) {
                w.write(line + "-" + name);
                System.out.println("学号");
                line = in.nextLine();
                System.out.println("学生姓名:");
                name = in.nextLine();
                w.write("\n");
            }
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
